#3000/s  在windows 32G内存 2G处理器
import tornado.ioloop
import tornado.web
import tornado.websocket,time
t1=time.time()
a=0
class SocketHandler(tornado.websocket.WebSocketHandler):
    def open(self):
        print("WebSocket opened")

    def on_message(self, message):
        global a,t2,t1
        a+=1
        if a%10000==0:
            t2=time.time()
            print(t2-t1,a)
            t1=t2
        # 可以选择回应消息
        self.write_message(u"You said: " + message)


    def on_close(self):
        print("WebSocket closed")

application = tornado.web.Application([
    (r"/ws", SocketHandler),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()